package com.oop;

public class Car implements Comparable<Car> {
  private String color;
  private int weight;

  public Car(String color, int weight) {
    this.color = color;
    this.weight = weight;
  }

  @Override
  public int compareTo(Car o) {
    return this.weight - o.weight;
  }

  public static void main(String[] args) {
    //
    Car c1 = new Car("green", 10);
    Car c2 = new Car("red", 20);
    System.out.println(c1.compareTo(c2));
  }
}
